package com.jinke.api.modules.third.myus56.model.response;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author huang
 * @data 2024-05-21
 */
@Getter
public enum ErrorEnums {
    ABNORMAL_ERROR(-1, "异常错误"),
    VERIFLCATION_FAILED(-2, "验证失败"),
    NOT_BALANCE(-4, "余额不足"),
    TRIAL_FAILURE(-6, "试算失败"),
    REQUEST_FAILED(-9, "请求失败");

    @EnumValue
    @JsonValue
    private final int value;
    private final String desc;

    ErrorEnums(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static ErrorEnums defaultEnum(int value) {
        for (ErrorEnums type : ErrorEnums.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("No element matches " + value);
    }
    }
